<template>
	<view class="parkList" @click="isshow=false">
		<view class="ppxx">
			以下是为您智能匹配的政策信息
		</view>
		<listPage type_name='policy' height='calc(100% - 40px)' :list='list' :total='0' @getMore='getMore'>
			<endlist :isLoad='isLoad' :isfinsh='isfinsh' :length='list.length'></endlist>
		</listPage>
	</view>
</template>

<script>
	import toplist from '@/components/toplist' 
	import endlist from '@/components/endlist' 
	import listPage from '@/components/listPage' 
	import { policy } from '../../utils/api.js'
	export default {
		data() {
			return {
				list:[],
				total:0,
				query:{
					page:1,
					keywords:'',
					chain_id:'',
					city_id:uni.getStorageSync('chooseCity').id
				},
				isshow:false,
				isfinsh:false,
				isLoad:false
			}
		},
		components: {
			toplist,
			endlist,
			listPage
		}, 
		onLoad(option){
			
			this.query.company_name = option.company_name
			this.query.chain_id = option.chain_id
			this.query.industry_id = option.industry_id
			
			this.changeInit()
		},
		onShow(){
			let chain,city
			city = uni.getStorageSync('chooseCity')
			if( (this.query.city_id==city.id)){
				return
			}else{
				this.query.city_id = city.id||''
				this.changeInit()
			}
		},
		methods: {
			showChain(){
				if(this.isshow == true){
					this.isshow = false
					return
				}
				this.isshow=true
			},
			toPage(page,type){
				uni.navigateTo({
					url:`/pages/${page}/${page}`
				})
			},
			changeQuery(query){
				this.query = Object.assign(this.query,query)
				this.changeInit()
			},
			changeInit(){
				this.total = 0
				this.list = []
				this.query.page=1
				this.isfinsh = false
				this.getPark()
			},
			getMore(){
				this.query.page+=1
				this.getPark()
			},
			toDetail(item){
				uni.navigateTo({
					url:`/pages/parkDetail/parkDetail?id=${item.id}`
				})
			},
			getPark(){
				if(this.isfinsh){
					return
				}
				this.isLoad = true
				policy.getList({...this.query}).then(res=>{
					if(this.query.page==1){
						this.list = res.data.data
					}else{
						this.list.push(...res.data.data)
					}
					this.total = res.data.total
					this.isLoad = false
					if(res.data.last_page == this.query.page){
						this.isfinsh=true
					}
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
page,.parkList{
	height: 100%;
}
.ppxx{
	height: 40px;
	line-height: 40px;
	padding-left: 10px;
	font-size: 18px;
	font-weight: 700;
	color: #1cbbff;
}


</style>
